<?php

class SsoWS_Service_Footstar
{
	private $_username = 'at-elah';
	private $_password = 'pscbta12';
	private $_pid = '7607';
	
	private $_urlTeamInfo = "?type=2&username={user}&password={password}&program_id={pid}&language={lang}&team_id={teamId}";
	private $_urlPlayers = "?type=3&username={user}&password={password}&program_id={pid}&language={lang}&player_id={playerId}";
	private $_urlFixture = "?type=4&username={user}&password={password}&program_id={pid}&language={lang}&team_id={teamId}";
	private $_urlLeagueTable = "?type=5&username={user}&password={password}&program_id={pid}&language={lang}&league_id={leagueId}&series_id={seriesId}&country={countryId}";
	
	private $_wsUrl = 'http://www.footstar.org/xml_feed.asp';
	
	
	
	
	private $_userId;
	private $_playerId;
	private $_teamId;
	
	
	//http://www.footstar.org/xml_feed.asp?type=1&username=at-elah&password=pscbta12&program_id=7607
	public function __construct()
	{
		$this->_urlTeamInfo = $this->_wsUrl . $this->_urlTeamInfo;
		$this->login( $this->_username, $this->_password, $this->_pid );
	}
	
	public function login( $user, $pass, $pid ) 
	{
		$xml = file_get_contents( 
			$this->_wsUrl . "?type=1". 
			"&username=". $user . 
			"&password=". $pass.
			"&program_id=".$pid
		);
		$obj = simplexml_load_string($xml);
		$this->_userId = $obj->user;
		$this->_playerId = $obj->player_id;
		$this->_teamId = $obj->team_id;
  	}
	
	public function getTeamInfo( $teamId )
	{
		$url = str_replace( "{user}", $this->_username, $this->_urlTeamInfo );
		$url = str_replace( "{password}", $this->_password, $url );
		$url = str_replace( "{pid}", $this->_pid, $url );
		$url = str_replace( "{lang}", 2, $url );
		$url = str_replace( "{teamId}", $teamId, $url );

		$xml = file_get_contents( $url );
		$obj = simplexml_load_string($xml);
		print_r($obj);
	}
}